<template>
    <router-link  class="card" :to="{name:'Detail', query: {id : item.id}}" tag="div">
        <div class="card-header">{{item.post_title}}</div>
        <div class="card-content">
            <div class="card-content-inner">{{item.post_excerpt || submsg }}</div>
        </div>
        <div class="card-footer">{{item.published_time}}<div class="pull-right" @click.stop="edit_item"><span class="icon icon-edit"></span></div></div>
    </router-link>
</template>


<script>

export default {
    name: 'IndexItem',
    props:[
        'item', 'aaa'
    ],
    computed:{
        submsg (){
            var msg = this.sub_item.post_content.replace(/<\/?[^>]*>/g, ''); //去除HTML Tag
            msg = msg.replace(/[|]*\n/, '') //去除行尾空格
            msg = msg.replace(/&npsp;/ig, ''); //去掉npsp
            return msg.substr(0,15);
        }
    },
    data(){
        return {
            sub_item: this.item
        }
    },
    methods:{
        edit_item(){
            $.toast("please register...");
            //this.sub_item.post_title = '12344'  //这里将会改变传递下来的item对象
        }
    },
    created: function(){
        //console.log(this.aaa);//测试传直接量
    }
}
</script>

<style>

</style>
